@extends('backstage.layout.master')
@section('title', '品牌认证详情')
@section('content')

    <link rel="stylesheet" href="assets/css/colorbox.css"/>
    <link rel="stylesheet" href="assets/css/ace.min.css"/>
    <link rel="stylesheet" href="assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="assets/css/ace-skins.min.css"/>
    <script src="assets/js/ace-extra.min.js"></script>
    <style>
        .images {
            width: 150px;
            height: 150px;
        }

        .col-xs-6 {
            padding: 0px;
        }

        .btn {
            margin: 5%;
        }

        .edit, .reset, .done {
            display: none;
        }
    </style>

    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li class="active">
                <a href="backstage/authentication/brand-list">品牌认证列表</a>
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="page-header">
            <h1>
                品牌详情
                <small>
                    <i class="icon-double-angle-right"></i>

                </small>
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-6">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        图片信息
                    </h1>
                </div>
                <div class="row-fluid">
                    <ul class="ace-thumbnails">
                        <li>
                            <a href=" {{$data->front_card_url}}" data-rel="colorbox">
                                <img class="images" src=" {{$data->front_card_url}}"/>
                                <div class="text">
                                    <div class="inner">身份证正面照</div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href=" {{$data->back_card_url}}" data-rel="colorbox">
                                <img class="images" src=" {{$data->back_card_url}}"/>
                                <div class="text">
                                    <div class="inner">身份证反面照</div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href=" {{$data->business_license_url}}"
                               data-rel="colorbox">
                                <img class="images"
                                     src=" {{$data->business_license_url}}">
                                <div class="text">
                                    <div class="inner">营业执照</div>
                                </div>
                            </a>
                        </li>
                        <li>
                            <a href=" {{$data->business_letters_url}}" data-rel="colorbox">
                                <img class="images" src=" {{$data->business_letters_url}}"/>
                                <div class="text">
                                    <div class="inner">企业公函</div>
                                </div>
                            </a>
                        </li>
                    </ul>
                </div><!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
            <div class="col-xs-6"
                 style="border-left: 1px dotted #e2e2e2;padding-bottom: 2%;border-bottom:1px dotted #e2e2e2; ">
                <div class="page-header">
                    <h1>
                        文字信息
                    </h1>
                </div>

                <form class="form-horizontal" role="form" action="backstage/authentication/update-brand-info"
                      method="post" enctype="multipart/form-data">
                    <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">

                    <div class="profile-user-info profile-user-info-striped">
                        <div class="profile-info-row">
                            <div class="profile-info-name">用户ID</div>
                            <div class="profile-info-value user_id">{{ $data->user_id}}</div>
                            <input value="{{$data->user_id}}" name="user_id" hidden="hidden">
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">公司全称</div>
                            <div class="profile-info-value dataInfo ">{{ $data->company_name}}</div>
                            <div class="profile-info-value edit">
                                <input name="company_name" value="{{ $data->company_name}}" class="edit"
                                       placeholder="公司全称"
                                       required="required">
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">公司简称</div>
                            <div class="profile-info-value id dataInfo">{{ $data->company_abbreviation}}</div>
                            <div class="profile-info-value edit">
                                <input name="company_abbreviation" value="{{ $data->company_abbreviation}}" class="edit"
                                       placeholder="公司简称"
                                       required="required">
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">管理员姓名</div>
                            <div class="profile-info-value id real_name dataInfo">{{ $data->manager_name}}</div>
                            <div class="profile-info-value edit">
                                <input name="manager_name" value="{{ $data->manager_name}}" class="edit"
                                       placeholder="管理员姓名"
                                       required="required">
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">身份证号</div>
                            <div class="profile-info-value id dataInfo"><span class="card_id">{{ $data->card_id}}</span>
                                @if($data->id_card_state == 0)
                                    <br/>
                                    <input type="button" class="check-card" value="审核身份证">
                                    <span style="color: red;">APP端未审核才会出现该按钮</span>
                                @endif
                            </div>
                            <div class="profile-info-value edit">
                                <input name="card_id" value="{{ $data->card_id}}" class="edit" placeholder="身份证号码"
                                       required="required">
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">管理员职位</div>
                            <div class="profile-info-value id dataInfo">{{ $data->job}}</div>
                            <div class="profile-info-value edit">
                                <input name="job" value="{{ $data->job}}" class="edit" placeholder="职位"
                                       required="required">
                            </div>
                        </div>

                        <div class="profile-info-row">
                            <div class="profile-info-name">手机号码</div>
                            <div class="profile-info-value id dataInfo">{{ $data->phone}}</div>
                            <div class="profile-info-value edit">
                                <input name="phone" value="{{ $data->phone}}" class="edit" placeholder="手机号码"
                                       required="required">
                            </div>
                        </div>


                    </div>
                    <div class="center">
                        <input type="submit" class="btn btn-success done" value="完成">
                        <input type="reset" class="btn reset" value="重置">
                    </div>
                </form>
                <div class="center">
                    @if($data->state == 0)
                        <button class="btn btn-info pass">
                            <i class="icon-ok bigger-110"></i>
                            审核通过
                        </button>
                        <button class="btn no-pass">
                            <i class="icon-remove bigger-110"></i>
                            取消审核
                        </button>
                    @endif

                    @if($data->state == 1)
                        <button class="btn no-pass">
                            <i class="icon-remove bigger-110"></i>
                            取消审核
                        </button>
                    @endif

                    @if($data->state == 2)
                        <br/>
                        <label>审核已拒绝:</label>
                        <br/>
                        <label style="color: red">{{$data->message}}</label>
                        <br/>
                        <button class="btn btn-info pass">
                            <i class="icon-ok bigger-110"></i>
                            审核通过
                        </button>
                    @endif

                    <input type="button" class="btn btn-primary update" value="修改信息">

                </div>
            </div>
        </div><!-- /.row -->
    </div><!-- /.page-content -->


    </div><!-- /.page-content -->
@stop
@section('script')

    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>

    <!-- page specific plugin scripts -->

    <script src="assets/js/jquery.colorbox-min.js"></script>

    <!-- ace scripts -->

    <script src="assets/js/ace-elements.min.js"></script>
    {{--<script src="assets/js/ace.min.js"></script>--}}

    <!-- inline scripts related to this page -->

    <script src="/front/hAdmin/js/plugins/layer/layer.js"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            var colorbox_params = {
                reposition: true,
                scalePhotos: true,
                scrolling: false,
                previous: '<i class="icon-arrow-left"></i>',
                next: '<i class="icon-arrow-right"></i>',
                close: '&times;',
                current: '{current} of {total}',
                maxWidth: '100%',
                maxHeight: '100%',
                onOpen: function () {
                    document.body.style.overflow = 'hidden';
                },
                onClosed: function () {
                    document.body.style.overflow = 'auto';
                },
                onComplete: function () {
                    $.colorbox.resize();
                }
            };

            $('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params);
            $("#cboxLoadingGraphic").append("<i class='icon-spinner orange'></i>");//let's add a custom loading icon

            /**$(window).on('resize.colorbox', function() {
		try {
			//this function has been changed in recent versions of colorbox, so it won't work
			$.fn.colorbox.load();//to redraw the current frame
		} catch(e){}
	});*/
        })
    </script>

    <script type="text/javascript">
        var user_id = $('.user_id').html();
        $(".pass").click(function () {
            swal({
                title: "是否通过审核？",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: true,
                closeOnCancel: true
            }, function () {
                $.ajax({
                    type: "get",
                    url: "backstage/authentication/pass-authentication",
                    data: {"user_id": user_id, 'type': 2},
                    success: function (msg) {
                        if (msg.state == "M00000") {
                            swal({
                                title: "操作成功",
                                text: "通过该用户认证审核,等待2秒自动刷新页面",
                                timer: 2000,
                                showConfirmButton: false
                            });
                            setTimeout("location.reload();", 2000);

                        } else {
                            showMessage(msg.message, "");
//                            location.reload();
                        }
                    },
                    error: function () {
                    }
                });
            });
        });


        $(".no-pass").click(function () {
            swal({
                title: "审核不通过",
                text: "请输入拒绝原因:",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                inputPlaceholder: "拒绝原因"
            }, function (inputValue) {
                if (inputValue === false) return false;
                if (inputValue === "") {
                    swal.showInputError("拒绝原因不能为空!");
                    return false
                } else {
                    $.ajax({
                        type: "post",
                        url: "backstage/authentication/refused-authentication",
                        data: {"user_id": user_id, 'type': 2, 'message': inputValue},
                        success: function (msg) {
                            if (msg.state == "M00000") {
                                swal("操作成功!", "拒绝原因: " + inputValue, "success");
                                setTimeout("location.reload();", 2000);
                            }
                        },
                        error: function () {
                        }
                    });
                }
            });
        });


        $(".check-card").click(function () {
            var real_name = $(".real_name").html();
            var card_id = $(".card_id").html();
            $.ajax({
                type: "post",
                url: "backstage/authentication/verified-card",
                data: {
                    "card_id": card_id,
                    'real_name': real_name,
                    'user_id': user_id,
                    'type': 2
                },
                success: function (msg) {
                    if (msg.state == "M00000") {
                        layer.msg('身份证实名通过!!');
                        setTimeout("location.reload();", 500);
                    } else if (msg.state == "M00003") {
                        layer.msg('身份证号码与姓名不符');
                    } else if (msg.state == "M00002") {
                        layer.msg('验证次数不足,请充值');
                    } else {
                        layer.msg('服务器繁忙!!');
                    }
                },
                error: function () {
                }
            });
        });

        $(".update").click(function () {
            $(".edit,.reset, .done").show();
            $(".dataInfo,.pass,.no-pass,.update").hide();
        });
    </script>
@stop